import Vue from 'vue';
import router from 'vue-router'; /* 导入路由 */

/* 导入其它页面(组件) */
import homepage from '../views/portal/homePage.vue'
import comInfo from '../views/portal/comInfo.vue'
import login from '../views/portal/login.vue'
import reg from '../views/portal/reg.vue'
import success from '../views/portal/success.vue';
import staffHome from '../views/myself/staffHome.vue'

import perList from '../views/admin/performance/list.vue';
import outAcc from '../views/admin/outAcc.vue';
import staffFlow from '../views/admin/staffFlow.vue';
import count from '../views/admin/count.vue';
import loginLog from '../views/admin/log/loginLog.vue';

import comInfoMeg from '../views/mesadmin/comInfoMeg.vue'
import article from '../views/portal/article.vue'
import articleInfo from '../views/portal/articleInfo.vue'
import articleMeg from '../views/mesadmin/articleMeg.vue'
import recruitInfo from '../views/portal/recruitInfo.vue'
import recruitMeg from '../views/mesadmin/recruitMeg.vue'

import staffMS from '../views/personnel/staffManagement'
import recriut from '../views/personnel/recruitmentManagement'
import training from '../views/personnel/trainingManagement'

import normalstaff from '../views/normalstaff/normalstaff.vue'
import seeSalary from '../views/normalstaff/seeSalary.vue'
import cultivate from '../views/normalstaff/cultivate.vue'

import finance from '../views/finance/finance.vue'
import traProgram from '../views/finance/traProgram.vue'
import attendTrain from '../views/finance/attendTrain.vue'
Vue.use(router)

/* 定义组件路由 */
const rout = new router({
	routes: [{
			path: "/login", //映射地址
			component: login //绑定组件
		},
		{
			path: "/reg", //映射地址
			component: reg //绑定组件
		},
		{
			path: "/succ",
			component: success,
			children: [
				{path: "/perList",component:perList},
		        {path: "/outAcc",component:outAcc},
				{path: "/staffFlow",component:staffFlow},
				{path: "/count",component:count},
				{path: "/loginLog",component:loginLog},
				
				{path:'/comInfoMeg',component:comInfoMeg},
				{path:'/articleMeg',component:articleMeg},
				{path:'/recruitMeg',component:recruitMeg},
				
                {path: "/staffManagement",component: staffMS}, 
				{path: "/trainingManagement",component: training}, 
				{path: "/recruitmentManagement",component: recriut},
				
				{path:'/normalstaff',component:normalstaff},
			  	{path:'/seeSalary',component:seeSalary},
				{path:'/cultivate',component:cultivate},
				
                {path: '/finance',component: finance},
				{path: '/traProgram',component: traProgram},
				{path: '/attendTrain',component: attendTrain}
				]
		 },
		{
			path: '/',
			component: homepage
		},
		{
			path: '/homepage', //映射地址
			name: 'homepage',
			component: homepage, //绑定组件
			redirect: '/comInfo',
			children: [
				{path: '/comInfo',component: comInfo},
				{path: '/article',component: article},
				{path: '/articleInfo',component: articleInfo},
				{path: '/recruitInfo',component: recruitInfo},
				{path: '/staffHome',component: staffHome}
			]
		}
	]
})

/* 导出路由组件 */
export default rout;

//路由导航守卫
/* rout.beforeEach((to, from, next) => {
  //如果用户访问的登录页， 直接放行
  if (to.path == '/homepage') {
    return next(); //to 要去的页面路由  next()向下走,放行
  } else {
    //const token = window.sessionStorage.getItem("token");
    // if (token == null) {
    //   return next("/homepage");
    // } else {
    //   next();
    // }
	return next("/homepage");
  }
}) */
